package com.lhh.myspringboot.java8;

import com.lhh.myspringboot.bean.Dog;

import java.util.ArrayList;
import java.util.List;

public class LambdaTest5 {

    public static void main(String[] args) {
        List<Dog> list=new ArrayList<>();
        list.add(new Dog("aa",1));
        list.add(new Dog("bb",4));
        list.add(new Dog("cc",3));
        list.add(new Dog("dd",2));
        list.add(new Dog("ee",5));
        // 排序
        System.out.println("lambda集合排序");
        list.sort((o1,o2)->o1.getAge()-o2.getAge());
        System.out.println(list);

        // 遍历集合
        System.out.println("lambda遍历集合");
        list.forEach(System.out::println);

    }
}
